package com.turing.mission.controller;

import com.alibaba.fastjson.JSONObject;
import com.turing.mission.entity.MissionApply;
import com.turing.mission.service.MissionApplyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import result.Result;

@RestController
public class ApplyController {

    @Autowired
    private MissionApplyService missionApplyService;

    @PostMapping("/apply/applySave")
    public Result applySave(@RequestBody JSONObject jsonObject){
        return missionApplyService.applySave(jsonObject);
    }

    @GetMapping("/apply/applyList")
    public Result applyList(
            @RequestParam(value = "merchantName" ,required = false) String merchantName,
            @RequestParam(value = "loginAccount" ,required = false) String loginAccount,
            @RequestParam(value = "maState" ,required = false) Integer maState,
            @RequestParam(value = "pageNum" ,required = false) Integer pageNum,
            @RequestParam(value = "pageSize" ,required = false) Integer pageSize
    ){
        return missionApplyService.applyList(merchantName,loginAccount,maState,pageNum,pageSize);
    }

    @GetMapping("/apply/getApplyById")
    public Result getApplyById(@RequestParam(value = "id") String id){
        return missionApplyService.getApplyById(id);
    }

    @DeleteMapping("/apply/deleteByIds")
    public Result deleteByIds(@RequestParam(value = "ids") String[] ids){
        return missionApplyService.deleteByIds(ids);
    }

    @PatchMapping("/apply/refuseApply")
    public Result refuseApply(@RequestBody JSONObject jsonObject){
        return missionApplyService.refuseApply(jsonObject);
    }

    @PatchMapping("/apply/missonSave")
    public Result missonSave(@RequestBody JSONObject jsonObject){
        return missionApplyService.missonSave(jsonObject);
    }
}
